package tn.jee.project.earProjectTweeter.ejb;




import javax.ejb.Stateless;

import javax.persistence.EntityManager;
//import javax.persistence.Query;


import tn.jee.earProject.model.Contact;
import tn.jee.earProject.model.Tweet;




@Stateless

public class MainModule {
  
	private EntityManager em;

    
    protected EntityManager getEntityManager() {
        return em;
    }
    
     public void tweet(Tweet t) {
        em.persist(t);

    }
     public void inscrire(Contact c){
         em.persist(c);
     }
     /* public Contact authenticate(String email, String pwd) throws javax.xml.bind.ValidationException {
        Contact contact;
        Query q0;
        if (email == null || "".equals(email)) {
            throw new ValidationException("Le nom du client est non valide");
        }
        String q = "SELECT c FROM Contact c WHERE c.email=:email";
        q0=em.createQuery(q);
        q0.setParameter("email", email);
        contact = (Contact) q0.getSingleResult();
        if (contact != null) {
        	
            contact.matchPassword(pwd);
        	
        }
        return contact; 


    }*/
     
    
   /* public List<Tweet> getTweets(Long contactId){
       // List<Tweet> all = new ArrayList<Tweet>();
        Contact c = em.find(Contact.class, contactId);
        
        
        String q = "Select object(t) from Tweet t"
                +"where t.contact.id =:c.id";
                
                
        
        
        Query qo = em.createQuery(q);
        qo.setParameter("C",c);
        qo.setMaxResults(50);
       
        return qo.getResultList();
    
    }*/
     
    
           
   
}
